package 临时工具.其他;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

public class ImageCreator {
    public static void main(String[] args) {
        int width = 1000;
        int height = 1000;

        // 创建一个RGB格式的空白图像
        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);

        for (int x = 0; x < width; x++) {
            for (int y = 0; y < height; y++) {
                // 填充每个像素为随机颜色
                int red = (int) (Math.random() * 256);
                int green = (int) (Math.random() * 256);
                int blue = (int) (Math.random() * 256);
                int rgb = (red << 16) | (green << 8) | blue;
                image.setRGB(x, y, rgb);
            }
        }

        // 可选：将图片保存为本地文件
        try {
            File output = new File("E:\\MyProject\\baichuan\\java-study\\src\\main\\java\\临时工具\\其他\\output.png");
            ImageIO.write(image, "png", output);
            System.out.println("图片已保存为 output.png");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
